﻿Imports System.Data.SqlClient
Public Class frmBajasNuevas
    Dim Bitacora As New clsActividad
    Private Sub frmBajasNuevas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CheckBox1.Checked = False

        Me.dgCargos.Rows.Clear()

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT B.IDEmpleado,B.fechabaja,B.causabaja,B.capturo,nombrecompleto From Bajas B INNER JOIN Empleados E ON b.idempleado=e.idempleado " & _
        " WHERE B.reportado='No' order by B.fechabaja"

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Do While rdBuscar.Read()
            Me.dgCargos.Rows.Add(rdBuscar("NombreCompleto"), rdBuscar("fechabaja"), rdBuscar("causabaja"), rdBuscar("capturo"))
        Loop
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
       
    End Sub

    Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click
        ToExcel(Me.dgCargos, "Relacion de nuevas bajas al " & Now())
    End Sub

    Private Sub RadButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton2.Click
        If Me.CheckBox1.Checked = True Then
            Call SetSqlCitra("Update Bajas set reportado='Si' where reportado='No'")
            'Registra actividad
            Bitacora.RegistraActividad("Revisó las notificaciones de nuevas bajas")
            Me.Close()
        Else
            Me.Close()
        End If
    End Sub
End Class